﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace TestApp
{
    public partial class TestsViewer : UserControl
    {
        public TestsViewer()
        {
            InitializeComponent();
        }

        private UIElement _currentTest;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var text = (string)((Button) sender).Content;
            var typeName = text.Replace(" ", string.Empty);
            var type = Assembly.GetExecutingAssembly().GetType(string.Format("TestApp.{0}", typeName));
            var constructor = type.GetConstructor(new Type[0]);
            var test = (UIElement) constructor.Invoke(new object[0]);
            if (_currentTest != null)
                TestDisplayGrid.Children.Remove(_currentTest);
            TestDisplayGrid.Children.Add(test);
            _currentTest = test;
        }
    }
}
